import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static void remove(List<String> list, String word) {
		for (Iterator<String> iterator = list.iterator(); iterator.hasNext();) {
			String str = (String) iterator.next();
			if (str.equals(word))
				iterator.remove();
		}
		
	}

	private static List<String> convertStringToList(String nextLine) {
		List<String> list=new ArrayList<String>();
		Scanner sc=new Scanner(nextLine);
		while(sc.hasNext()){
			list.add(sc.next());
		}
		sc.close();
		return list;
	}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            List<String> list = convertStringToList(sc.nextLine());
            System.out.println(list);
            String word = sc.nextLine();
            remove(list,word);
            System.out.println(list);
        }
        sc.close();
    }

}
